class Solution {
public:
    bool check(char* str1, char* str2)
    {
        for (int i = 0; i < 26; i++)
        {
            if (str1[i] != str2[i])
            {
                return false;
            }
        }
        return true;
    }
    vector<int> findAnagrams(string s, string p) {
        int n = s.size();
        int size = p.size();
        //unordered_map <int,int> hashp,hashs;
        char hashp[26] = { 0 };
        char hashs[26] = { 0 };
        for (auto e : s)
        {
            hashp[e - 'a']++;
        }
        for (int i = 0; i < size; i++)
        {
            hashs[s[i] - 'a']++;
        }
        int left = 0, right = 0;
        vector<int> ret;
        while (right < n)
        {
            if (check(hashp, hashs))
            {
                ret.push_back(left);
            }
            hashs[s[left] - 'a']--, hashs[s[right] - 'a']++;

            left++, right++;
        }
        return ret;
    }
};